import { useWindowSize } from '@vueuse/core'
import { computed} from 'vue'
import {PC_WIDTH_SIZE,MAX_FONT_SIZE}  from '@/constants/index.js'
const { width } = useWindowSize()  
export const isMobile =computed(()=> width.value<PC_WIDTH_SIZE)
export const setAotuFontSize = ()=>{
    //当html加载完毕后获取当前窗口的宽度,根据宽度/10动态计算我们所需要的fontSize最大为40px
    document.addEventListener("DOMContentLoaded",()=>{
        window.localStorage.setItem('MAX_RELOAD_TIMES',0)
        const html = document.documentElement
        const fontSize = html.getBoundingClientRect().width/10
        html.style.fontSize = fontSize<MAX_FONT_SIZE?fontSize+'px':MAX_FONT_SIZE+'px'
    })
}

